/*******************************************************************************
 Configuration Information:
 Repository: Integrity Source
 Name      : $RCSfile: AR_CD_LKAColTqCalc_tl_lut.c $
 Version   : $Revision: 1.5 $
 Author    : $Author: Jack Jin (JinC5) $
 Date      : $Date: 2018/09/14 18:33:12IST $
 Location  : $ProjectName: /Steering/Projects/Geely/CMA_DP/PR48756_LVS_ENG_APP_Geely_CMA_EPS_DP_SYS_HRoom_AP/30_Software/3040_Design/S2-Application/01-Development/V00-Mainline/04-Components/ActiveReturn_Ear/Source/project.pj $
********************************************************************************

   ZF Friedrichshafen AG owns the copyright in this document and associated
   documents and all rights are reserved.  These documents must
   not be used for any purpose other than that for which they
   are supplied and must not be copied in whole or in part or
   disclosed to others without prior written consent of ZF Friedrichshafen AG.
   Any copy of this drawing or document made by any method
   must also include a copy of this legend.

   (C) ZF Friedrichshafen AG 2018

*******************************************************************************/
/**************************************************************************************************\
 *** 
 *** Simulink model       : AR_CD_LKAColTqCalc_tl
 *** TargetLink subsystem : AR_CD_LKAColTqCalc_tl
 *** Codefile             : AR_CD_LKAColTqCalc_tl_lut.c
 ***
 *** Generated by TargetLink, the dSPACE production quality code generator
 *** Model version: 1.124
 *** Generation date: 2018-09-14 11:00:51
 ***
 *** CODE GENERATOR OPTIONS:
 *** Code generation mode                     : AUTOSAR
 *** AUTOSAR version                          : 4.2.2
 *** Compiler                                 : <unknown>
 *** Target                                   : Generic
 *** ANSI-C compatible code                   : yes
 *** Code Optimization                        : enabled
 *** Constant style                           : decimal
 *** Clean code option                        : enabled
 *** Logging mode                             : Do not log anything
 *** Code Coverage                            : disabled
 *** Generate empty conditional branches      : disabled
 *** Loop unroll threshold                    : 5
 *** Shift mode                               : automatic
 *** Handle unscaled SF expr. with TL type    : enabled
 *** Assignment of conditions                 : AllBooleanOutputs 
 *** Scope reduction only to function level   : disabled
 *** Exploit ranges if not erasable           : disabled
 *** Exploit Compute Through Overflow         : never
 *** Linker sections                          : enabled
 *** Enable Assembler                         : disabled
 *** Variable name length                     : unlimited
 *** Use global bitfields                     : disabled
 *** Stateflow: use of bitfields              : enabled
 *** State activity encoding limit            : 8
 *** Omit zero inits in restart function      : disabled
 *** Share functions between TL subsystems    : disabled
 *** Generate 64bit functions                 : disabled
 *** Inlining Threshold                       : 6
 *** Line break limit                         : 100
 *** Target optimized boolean data type       : enabled
 *** Keep saturation elements                 : disabled
 *** Extended variable sharing                : disabled
 *** Extended lifetime optimization           : enabled
 *** Style definition file                    : C:\Program Files\dSPACE TargetLink 4.2\Matlab\Tl\Con
 ***                                            fig\codegen\cconfig.xml
 *** Root style sheet                         : C:\Program Files\dSPACE TargetLink 4.2\Matlab\Tl\XML
 ***                                            \CodeGen\Stylesheets\TL_CSourceCodeSS.xsl
 ***
 *** SUBSYS                   CORRESPONDING SIMULINK SUBSYSTEM
 *** SAR_CD_091               AR_CD_LKAColTqCalc_tl
 *** SAR_CD_092               AR_CD_LKAColTqCalc_tl/AR_CD_LKAColTqCalc
 *** SAR_CD_093               AR_CD_LKAColTqCalc_tl/DocFunction
 *** SAR_CD_094               AR_CD_LKAColTqCalc_tl/IncludeAppHeader
 *** SAR_CD_095               AR_CD_LKAColTqCalc_tl/AR_CD_LKAColTqCalc/CompareTo Zero1
 *** SAR_CD_096               AR_CD_LKAColTqCalc_tl/AR_CD_LKAColTqCalc/ZFDivA_fabs2
 *** SAR_CD_097               AR_CD_LKAColTqCalc_tl/DocFunction/EmptySubsystem
 *** 
 *** SUBSYS                   CORRESPONDING MODEL BLOCK (REFERENCED MODEL)
 *** 
 *** SF-NODE   CORRESPONDING STATEFLOW NODE                           DESCRIPTION
 *** 
 *** TargetLink version      : 4.2p2 from 27-Nov-2017
 *** Code generator version  : Build Id 4.2.0.33 from 2017-11-28 14:39:24

\**************************************************************************************************/

#ifndef AR_CD_LKACOLTQCALC_TL_LUT_C
#define AR_CD_LKACOLTQCALC_TL_LUT_C

/*----------------------------------------------------------------------------*\
  DEFINES (OPT)
\*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*\
  INCLUDES
\*----------------------------------------------------------------------------*/

#include "AR_CD_LKAColTqCalc_tl_lut.h"

/*----------------------------------------------------------------------------*\
  ENUMS
\*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*\
  DEFINES
\*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*\
  TYPEDEFS
\*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*\
  VARIABLES
\*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*\
  PARAMETERIZED MACROS
\*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*\
  FUNCTION PROTOTYPES
\*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*\
  INLINE FUNCTIONS
\*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*\
  FUNCTION DEFINITIONS
\*----------------------------------------------------------------------------*/

/**************************************************************************************************\
 ***  FUNCTION:
 ***      Tab2DIntp2I1T207878_AR_CD_09
 *** 
 ***  DESCRIPTION:
 ***      Automatic generated function for Interpolation using PreLook-Up blocks.
 *** 
 ***  PARAMETERS:
 ***      Type               Name                Description
 ***      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ***      const float32 *    z_table             pointer to table vector
 ***      uint8              N                   number of values in y-axis vector
 ***      UInt8              irx                 1. table input index
 ***      Float32            fractionX           1. table input fraction
 ***      uint32             iry                 2. table input index
 ***      float32            fractionY           2. table input fraction
 ***
 ***  RETURNS:
 ***      float32
 ***
 ***  SETTINGS:
 ***      Number of table dimensions.........: 2
 ***      Interpolation......................: on
 ***      Distances fit into given bitlengths: no
 ***
\**************************************************************************************************/
float32 Tab2DIntp2I1T207878_AR_CD_09(const float32 * z_table, uint8 N, UInt8 irx, Float32 fractionX,
   uint32 iry, float32 fractionY)
{
   /* SLLocal: Default storage class for local variables | Width: 32 */
   float32 Aux_F32;
   float32 Aux_F32_a;
   float32 Aux_F32_b;

   z_table += (((uint32) (uint16) (((uint16) irx) * ((uint16) N))) + iry);
   Aux_F32 = z_table[0];
   if (fractionY == 0.F) {
      if (fractionX == 0.F) {
         return Aux_F32;
      }
      Aux_F32_a = z_table[N];
   }
   else {
      /* 1. Y-Interpolation. */
      Aux_F32_b = z_table[1];
      Aux_F32 += ((Aux_F32_b - Aux_F32) * fractionY);
      if (fractionX == 0.F) {
         return Aux_F32;
      }
      z_table += N;

      /* 2. Y-Interpolation. */
      Aux_F32_a = *(z_table++);

      /* X-Interpolation. */
      Aux_F32_b = z_table[0];
      Aux_F32_a += ((Aux_F32_b - Aux_F32_a) * fractionY);
   }
   if (fractionX != 0.F) {
      Aux_F32 += ((Aux_F32_a - Aux_F32) * fractionX);
   }
   return Aux_F32;
}

/**************************************************************************************************\
 ***  FUNCTION:
 ***      TabIdxS48T3222_AR_CD_09
 *** 
 ***  DESCRIPTION:
 ***      Automatic generated function for PreLook-Up Index Search blocks.
 *** 
 ***  PARAMETERS:
 ***      Type               Name                Description
 ***      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ***      const float32 *    x_table             pointer to x-axis vector
 ***      uint32             N                   number of values in x-axis vector
 ***      float32            x                   table input
 ***      uint32 *           irx                 table output
 ***      float32 *          fraction            table output
 ***
 ***  RETURNS:
 ***      void
 ***
 ***  SETTINGS:
 ***      Search algorithm...................: ascending linear search.
 ***      Output configuration...............: output index and fraction, two variables
 ***
\**************************************************************************************************/
void TabIdxS48T3222_AR_CD_09(const float32 * x_table, uint32 N, float32 x, uint32 * irx, float32 *
  fraction)
{
   /* SLLocal: Default storage class for local variables | Width: 32 */
   uint32 Aux_U32;

   /* Saturation. */
   if (x <= *x_table) {
      *irx = 0;
      *fraction = 0.F;
   }
   else {
      if (x >= x_table[N - 1]) {
         *irx = N - 1;
         *fraction = 0.F;
      }
      else {
         Aux_U32 = 0;

         /* Linear search, start low. */
         x_table++;
         while (x >= *(x_table++)) {
            Aux_U32++;
         }
         x_table -= 2;
         *irx = Aux_U32;
         *fraction = (x - x_table[0]) / (x_table[1] - x_table[0]);
      }
   }
}

/*----------------------------------------------------------------------------*\
  MODULE LOCAL FUNCTION DEFINITIONS
\*----------------------------------------------------------------------------*/
#endif /* AR_CD_LKACOLTQCALC_TL_LUT_C */
/*----------------------------------------------------------------------------*\
  END OF FILE
\*----------------------------------------------------------------------------*/
